package org.alanlau.spring.prosyfactorybean;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;

/**
 * @author alan
 * @version 1.0
 * @date 2020/1/12 10:40
 */
public class MyAspect implements MethodInterceptor {
    @Override
    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        // 前置增强
        check();
        except();
        // 执行目标方法
        Object obj = methodInvocation.proceed();
        // 后置增强
        log();
        monitor();
        return obj;
    }

    public void check() {
        System.out.println("模拟权限控制");
    }

    public void except() {
        System.out.println("模拟异常处理");
    }

    public void log() {
        System.out.println("模拟日志记录");
    }

    public void monitor() {
        System.out.println("模拟性能监测");
    }
}
